<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>坦克大战 Online - 房间列表</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #222;
            font-family: Arial, sans-serif;
            color: white;
        }
        .container {
            width: 80%;
            max-width: 800px;
            background-color: rgba(0, 0, 0, 0.7);
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
        }
        h1 {
            text-align: center;
            color: #4CAF50;
            margin-bottom: 30px;
        }
        .room-list {
            margin-bottom: 30px;
        }
        .room-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px;
            margin-bottom: 10px;
            background-color: #333;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        .room-item:hover {
            background-color: #444;
        }
        .room-info {
            display: flex;
            flex-direction: column;
        }
        .room-name {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 5px;
        }
        .player-count {
            font-size: 14px;
            color: #aaa;
        }
        .join-button {
            padding: 8px 15px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .join-button:hover {
            background-color: #45a049;
        }
        .action-buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
        }
        .action-button {
            padding: 12px 20px;
            font-size: 16px;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
            width: 48%;
        }
        .random-join {
            background-color: #2196F3;
        }
        .random-join:hover {
            background-color: #0b7dda;
        }
        .create-room {
            background-color: #4CAF50;
        }
        .create-room:hover {
            background-color: #45a049;
        }
        .loading {
            text-align: center;
            font-size: 18px;
            margin: 20px 0;
        }
        .no-rooms {
            text-align: center;
            font-size: 18px;
            margin: 30px 0;
            color: #aaa;
        }
        .refresh-button {
            display: block;
            margin: 0 auto 20px;
            padding: 8px 15px;
            background-color: #607d8b;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .refresh-button:hover {
            background-color: #546e7a;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>坦克大战 Online</h1>
        
        <button id="refresh-button" class="refresh-button">刷新房间列表</button>
        
        <div id="loading" class="loading">正在加载房间列表...</div>
        
        <div id="room-list" class="room-list" style="display: none;">
            <!-- 房间列表将通过JavaScript动态生成 -->
        </div>
        
        <div id="no-rooms" class="no-rooms" style="display: none;">
            当前没有可用的房间，请创建一个新房间开始游戏！
        </div>
        
        <div class="action-buttons">
            <button id="random-join" class="action-button random-join">随机加入</button>
            <button id="create-room" class="action-button create-room">创建房间</button>
        </div>
    </div>

    <script src="/socket.io/socket.io.js"></script>
    <script src="/js/rooms.js"></script>
</body>
</html>